package com.myk.game.ghosts.pages;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.myk.game.ghosts.databinding.PageHomeBinding;
import com.myk.game.ghosts.interfaces.IMainController;
import com.myk.game.lib.base.AbsBasePage;

/**
 * 首页
 */
public class HomePage extends AbsBasePage<PageHomeBinding> {

    private final IMainController controller;

    public HomePage(@NonNull Context context) {
        super(context);
        this.controller = (IMainController) context;
        binding.cbToggleMusic.setChecked(controller.isMusicPlaying());
        binding.cbToggleMusic.setOnCheckedChangeListener((buttonView, isChecked) -> {
            if (isChecked) controller.openBgMusic();
            else controller.closeBgMusic();
        });
        binding.tvJumpToGame.setOnClickListener(v -> controller.jumpGamePage());
    }

}
